package org.mark.storage.controller;

import org.mark.common.response.Result;
import org.mark.storage.entity.StorageInfo;
import org.mark.storage.service.StorageInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 储位信息
 */
@RestController
@RequestMapping("/storage")
@CrossOrigin
public class StorageInfoController {

    @Resource
    private StorageInfoService storageInfoService;

    @GetMapping("/page")
    public Result page(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam(required = false) String name) {
        return storageInfoService.page(pageNum, pageSize, name);
    }

    @PostMapping("/save")
    public Result save(@RequestBody StorageInfo storageInfo) {
        return storageInfoService.save(storageInfo);
    }

    @PostMapping("/update")
    public Result update(@RequestBody StorageInfo storageInfo) {
        return storageInfoService.update(storageInfo);
    }

    @DeleteMapping("/remove/{id}")
    public Result remove(@PathVariable Integer id) {
        return storageInfoService.remove(id);
    }

    @GetMapping("/list")
    public Result list() {
        return storageInfoService.list();
    }

    @GetMapping("/inventory")
    public Result getStorageInventory() {
        return storageInfoService.getStorageInventory();
    }
}